<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>网站信息</title>  
    <link rel="stylesheet" href="/Public/Admin/css/pintuer.css">
    <link rel="stylesheet" href="/Public/Admin/css/admin.css">
    <script src="/Public/Admin/js/jquery.js"></script>
    <script src="/Public/Admin/js/pintuer.js"></script>  
    <script src="/Public/js/jquery-2.1.1.min.js"></script>  
	
    <script src="/Public/js/layer/layer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong class="icon-reorder"> 图文信息</strong></div>
 <form method="post" action="{:U('Message/index')}" id="listform">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    
    <table class="table table-hover text-center">
      <tr>
        
        
        <th style="width:300px;">序号</th>
        <th style="width:300px;">标题</th>
        <th style="width:300px;">内容（可以为空）</th>
        <th style="width:300px;">图片链接（第一条会显示图片）</th>
        <th style="width:300px;">链接地址（地址错误则会影响自动回复）</th>
        <th style="width:300px;">操作</th>
      </tr>
      <volist name="list" id="vo" key='k'>
        <tr>
          
          <td style="width:300px;" id="id{$k}">{$vo.id}</td>
          <td style="width:300px;" id="title{$k}">{$vo.title}</td>
          <td style="width:300px;" id="description{$k}">{$vo.description}</td>
          <td style="width:300px;" id="picurl{$k}">{$vo.picurl}</td>
          <td style="width:300px;" id="url{$k}">{$vo.url}</td>
          <td style="width:300px;"><a href="javascript:void(0)" id="editd{$k}" class="button border-main icon-search" onclick="edit({$k})" >编辑</a></td>
          
          
        </tr>
   		  </volist>
      
      <tr>
        
      </tr>
    </table>
  </div>
</form>
  <div class="pagelist"> <ul>{$page}</ul></div>
</div>
<script>
function del(id){
	if(confirm("您确定要删除吗?")){
		
		document.location.href="{:U('Member/del')}?id="+id;
	}
}
//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})
//批量删除
function DelSelect(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;
		else
		$("#listform").submit();		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}
function changesearch(){
	$("#listform").submit();	
}

function edit(num){
		console.log($("#editd"+num).html());
	if('编辑' == $("#editd"+num).html() ){
		var title = $("#title"+num).html();
		var description = $("#description"+num).html();
		var picurl = $("#picurl"+num).html();
		var url = $("#url"+num).html();
		$("#title"+num).html("<input name='title"+num+"' value='"+title+"' />");
		$("#description"+num).html("<input name='description"+num+"' value='"+description+"' />");
		$("#picurl"+num).html("<input name='picurl"+num+"' value='"+picurl+"' />");
		$("#url"+num).html("<input name='url"+num+"' value='"+url+"' />");
		$("#editd"+num).html('保存');
	}else{
	    var id=$("#id"+num).html();
		var title = $("input[name='title"+num+"']").val();
		var description = $("input[name='description"+num+"']").val();
		var picurl = $("input[name='picurl"+num+"']").val();
		var url = $("input[name='url"+num+"']").val();
		//alert(picurl);
		$.ajax({
			url:"{:U('Pic/edit')}",
			type:"post",
			data:{'id':id,'title':title,'description':description,'picurl':picurl,'url':url},
			dataType:"JSON",
			success:function (data){
				layer.msg(data.info);
				if(data.status == 1){
					$("#title"+num).html(title);
					$("#description"+num).html(description);
					$("#picurl"+num).html(picurl);
					$("#url"+num).html(url);
					$("#editd"+num).html('编辑');
				}
			}
		})
	
	}
}


</script>

</body></html><SCRIPT Language=VBScript><!--

//--></SCRIPT>